home *** CD-ROM | disk | FTP | other *** search
- Subject: ccl;INTERFACE:Hyper-Display-Demo.lisp
- Received: from apple.com by goofy.apple.com with SMTP (5.61/25-eef) id AA15414; Tue, 26 Jun 90 09:52:35 -0700 for Zukoski1@HyperMail.apple.com
- Received: from dime.cs.umass.edu by apple.com with SMTP (5.61/25-eef) id AA25380; Tue, 26 Jun 90 09:52:29 -0700 for Zukoski1@HyperMail.apple.com
- Received: from vax1.cs.umass.edu by dime.cs.umass.edu (5.61/Ultrix2.0-B) id AA04358; Tue, 26 Jun 90 12:51:59 -0400
- Date: Tue, 26 Jun 90 12:48 EST
- From: "Dan Suthers (413) 665-8929" <SUTHERS@cs.umass.EDU>
- Subject: ccl;INTERFACE:Hyper-Display-Demo.lisp
- To: Zukoski1
- Message-Id: <7394DE013CBF80117B@cs.umass.EDU>
- X-Envelope-To: Zukoski1@HyperMail.Apple.COM
- X-Vms-To: IN%"Zukoski1@HyperMail.Apple.COM"
- X-Vms-Cc: SUTHERS
- Received: by HyperMail from goofy.apple.com with smtp id 3605; Tue, 26 Jun 90 09:57:56 PDT
- Received: by Zukoski1 id 15973; Tue, 26 Jun 1990 13:31:59 PST
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; File: Hyper-Demo.lisp
- ; Author: Dan Suthers
- ; Created: 02-July-89 14:27:32
- ; Modified: 26-Jun-90 12:38:58 (Dan Suthers)
- ; Language: Common Lisp
- ; Package: hyper-display
- ;
- ; Description: Demonstrates the Hyper-Display by putting up a short
- ; text (a diagnostic summary in the domain of psycho-
- ; educational assessment) with hypertext access to further
- ; detail and definitions.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (in-package :hyper-display)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; CODE
- ;;; All this is general, and could be copied and used for an application.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Command definitions. (Functions are embedded in lambdas because they
- ;;; reference the command list recursively.)
-
- (defparameter *COMMANDS*
- (list (list #\d "Define this."
- #'(lambda (hs w) (definer hs w)))
- (list #\e "Expand on this."
- #'(lambda (hs w) (expander hs w)))
- (list #\r "Return to previous text."
- #'(lambda (hs w) (declare (ignore hs))
- (pop-structure w)))
- (list #\i "Inspect Structure."
- #'(lambda (hs w) (declare (ignore w))
- (inspect hs)))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Display windows. Must be defined after *commands* but before functions.
-
- (eval-when (eval compile load)
-
- (defparameter *DEFINITION-WINDOW*
- (create-hyper-display (make-hyper-structure)
- *commands*
- :window-size (make-point 450 120)
- :right-margin 53
- :window-position (make-point 2 260)
- :window-title "Definitions"))
-
- (defparameter *TEXT-WINDOW*
- (create-hyper-display (make-hyper-structure)
- *commands*
- :window-title "Psycho-Educational Assessment"
- :window-size (make-point 450 200)
- :right-margin 60
- :window-position
- (make-point 2 *menubar-bottom*)))
-
- )
-
- (defun DEFINER (hs w)
- (declare (ignore w))
- (if (eq :term (first (hyper-structure-object hs)))
- (let ((obj (second (hyper-structure-object hs))))
- (if (and (symbolp obj)
- (hyper-structure-p (get obj :definition)))
- (push-to-structure (get obj :definition) *definition-window*)
- (wind:message-dialogue
- "This term should have a definition, but I can't find it.")))
- (wind:message-dialogue
- "Your selection isn't a term (cannot have a definition).")))
-
- (defun EXPANDER (hs w)
- (if (member (first (hyper-structure-object hs))
- '(:definition :phrase :statement))
- (let ((obj (second (hyper-structure-object hs))))
- (if (and (symbolp obj)
- (hyper-structure-p (get obj :expansion)))
- (push-to-structure (get obj :expansion) w)
- (wind:message-dialogue
- "I can't find more detail on your selection."
- )))
- (wind:message-dialogue
- "Your selection isn't a phrase or statement (can't be expanded into more detail)."
- )))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Display management.
-
- ;;; Definitions displayed in dedicated window, replacing previous contents.
- ;;; Existing code handles it.
-
- ;;; Expansions get displayed in the same window, with option to pop to
- ;;; previous context.
-
- (defun PUSH-TO-STRUCTURE (text-structure hd-window)
- (declare (object-variable hyper-structure))
- (setf (hyper-structure-parent text-structure)
- (ask hd-window hyper-structure))
- (display-hyper-structure text-structure hd-window))
-
- (defun POP-STRUCTURE (hd-window)
- (declare (object-variable hyper-structure))
- (let ((parent (hyper-structure-parent (ask hd-window hyper-structure))))
- (if parent
- (display-hyper-structure parent hd-window)
- (wind:message-dialogue "There is no parent text to return to."))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; DEMO TEXT
- ;;; The following is domain-specific text, for the purposes of this demo.
- ;;; Normally this stuff might be automatically generated as needed from
- ;;; internal knowledge-base structures.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Statements
-
- (defparameter *TOP-LEVEL-SUMMARY*
- (let* (
- (f3p
- (make-hyper-structure :text-specs '("Factor-3 Profile")
- :object '(:term factor-3-profile)))
- (WR
- (make-hyper-structure :text-specs '("WISC-R")
- :object '(:term wisc-r)))
- (interp-WR
- (make-hyper-structure
- :text-specs (list "First I interpreted the "
- WR
- ", identifying a "
- f3p
- ".")
- :object '(:statement interp-wr)))
- (ADD
- (make-hyper-structure :text-specs '("A.D.D.")
- :object '(:term add)))
- (suggest-ADD
- (make-hyper-structure
- :text-specs (list "This suggested the "
- ADD
- " hypothesis")
- :object '(:statement suggest-add)))
- (other-obs
- (make-hyper-structure :text-specs '("other inconsistent observations")
- :object '(:phrase other-obs)))
- (eval-reject-ADD
- (make-hyper-structure
- :text-specs (list "which I evaluated but rejected due to "
- other-obs
- ".")
- :object '(:phrase eval-reject-add)))
- (emotional-factors
- (make-hyper-structure :text-specs '("emotional factors")
- :object '(:phrase emotional-factors)))
- (bore-hyper
- (make-hyper-structure :text-specs '("boredom-induced hyperactivity")
- :object '(:phrase bore-hyper)))
- (diagnosis
- (make-hyper-structure
- :text-specs (list "My diagnosis is a combination of "
- emotional-factors
- " and "
- bore-hyper
- ".")
- :object '(:statement diagnosis)))
- (summary
- (make-hyper-structure
- :text-specs (list "Diagnostic Summary: "
- interp-WR
- " "
- suggest-ADD
- ", "
- eval-reject-ADD
- " "
- diagnosis)
- :object '(:statement summary))))
- (setf (hyper-structure-parent f3p) interp-WR)
- (setf (hyper-structure-parent WR) interp-WR)
- (setf (hyper-structure-parent interp-WR) summary)
- (setf (hyper-structure-parent ADD) suggest-ADD)
- (setf (hyper-structure-parent suggest-ADD) summary)
- (setf (hyper-structure-parent other-obs) eval-reject-ADD)
- (setf (hyper-structure-parent eval-reject-ADD) summary)
- (setf (hyper-structure-parent emotional-factors) diagnosis)
- (setf (hyper-structure-parent bore-hyper) diagnosis)
- (setf (hyper-structure-parent diagnosis) summary)
- summary))
-
- (setf
- (get 'SUGGEST-ADD :expansion)
- ;; I need generators for structures reused, since each should be unique. But
- ;; each unique structure needs backpointer to yet-to-be created suggest-add.
- ;; Solution is to keep track.
- (let ((children-of-suggest-add nil))
- (flet ((f3p-gen ()
- (push
- (make-hyper-structure :text-specs '("Factor-3 Profile")
- :object '(:term factor-3-profile))
- children-of-suggest-add)
- (first children-of-suggest-add))
- (ADD-gen ()
- (push
- (make-hyper-structure :text-specs '("A.D.D.")
- :object '(:term add))
- children-of-suggest-add)
- (first children-of-suggest-add))
- (f3s-gen ()
- (push
- (make-hyper-structure :text-specs '("Factor-3 Subscale")
- :object '(:term factor-3-subscale))
- children-of-suggest-add)
- (first children-of-suggest-add))
- (stm-gen ()
- (push
- (make-hyper-structure :text-specs '("short-term memory")
- :object '(:term stm))
- children-of-suggest-add)
- (first children-of-suggest-add)))
- (let ((suggest-add
- (make-hyper-structure
- :text-specs
- (list
- (f3p-gen)
- " is evidence for "
- (add-gen)
- " for the following reason. "
- "All three subscales on the "
- (f3s-gen)
- " involve retention of information in "
- (stm-gen)
- " while carrying out the task. "
- "A person with an attentional deficit is likely to be distracted by other thoughts or external stimuli,"
- " which replace the information in "
- (stm-gen)
- ". The disruption of "
- (stm-gen)
- " makes it difficult for such persons to complete the tasks on the "
- (f3s-gen)
- ", so "
- (add-gen)
- " is suspected when these scores are depressed."
- "(see definition of "
- (f3p-gen)
- ").")
- :object '(:statement suggest-add))))
- (dolist (c children-of-suggest-add)
- (setf (hyper-structure-parent c) suggest-add))
- suggest-add))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Definitions
-
- (setf
- (get 'ADD :definition)
- (make-hyper-structure
- :text-specs
- '("A.D.D.: Attention Deficit Disorder.")
- :object '(:definition add)))
-
- (setf
- (get 'ADD :expansion)
- (let* ((dsm-iii
- (make-hyper-structure
- :text-specs '("DSM-III")
- :object '(:definition dsm-iii)))
- (add
- (make-hyper-structure
- :text-specs
- (list "Attention Deficit Disorder (A.D.D.) is a diagnostic category of the "
- DSM-iii
- ". It is defined to be present when ...")
- :object '(:definition add))))
- (setf (hyper-structure-parent dsm-iii) add)
- add))
-
- (setf
- (get 'APTITUDE-TEST :definition)
- (let* (
- (psychometric
- (make-hyper-structure :text-specs '("psychometric test")
- :object '(:term psychometric)))
- (achievement
- (make-hyper-structure :text-specs '("achievement")
- :object '(:term achievement)))
- (apt-test
- (make-hyper-structure
- :text-specs (list "Aptitude Test: a "
- psychometric
- " which is designed to measure inherent intellectual ability and potential,"
- " as opposed to "
- achievement
- " (learned behaviors).")
- :object '(:definition aptitude-test))))
- (setf (hyper-structure-parent psychometric) apt-test)
- (setf (hyper-structure-parent achievement) apt-test)
- apt-test))
-
- (setf
- (get 'DSM-III :definition)
- (make-hyper-structure
- :text-specs
- '("DSM-III: Diagnostic and Statistical Manual, which defines categories of psychological disorders.")
- :object '(:definition dsm-iii)))
-
- (setf
- (get 'FACTOR-3-PROFILE :definition)
- (let* ((WR
- (make-hyper-structure :text-specs '("WISC-R")
- :object '(:term wisc-r)))
- (coding
- (make-hyper-structure :text-specs '("Coding")
- :object '(:term coding)))
- (digit-span
- (make-hyper-structure :text-specs '("Digit Span")
- :object '(:term digit-span)))
- (arithmetic
- (make-hyper-structure :text-specs '("Arithmetic")
- :object '(:term arithmetic)))
- (f3p
- (make-hyper-structure
- :text-specs
- (list "Factor-3 Profile: A pattern of results on the "
- WR
- " test. "
- "This pattern is present when three subscales ("
- Coding
- ", "
- Digit-Span
- ", and "
- Arithmetic
- ") are significantly depressed relative to the other 9 subscales.")
- :object '(:definition factor-3-profile))))
- (setf (hyper-structure-parent WR) f3p)
- (setf (hyper-structure-parent coding) f3p)
- (setf (hyper-structure-parent digit-span) f3p)
- (setf (hyper-structure-parent arithmetic) f3p)
- f3p))
-
- (setf
- (get 'PSYCHOMETRIC :definition)
- (make-hyper-structure
- :text-specs
- '("Psychometric test: a test designed to measure some psychological characteristic.")
- :object '(:definition psychometric)))
-
- (setf
- (get 'WISC-R :definition)
- (let* (
- (apt-test
- (make-hyper-structure :text-specs '("aptitude test")
- :object '(:term aptitude-test)))
- (definition
- (make-hyper-structure
- :text-specs (list
- "WISC-R: Weschler Intelligence Scale for Children, Revised. "
- "A widely used "
- apt-test
- ".")
- :object '(:definition wisc-r)))
- )
- (setf (hyper-structure-parent apt-test) definition)
- definition))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Get things started.
-
- (display-hyper-structure *top-level-summary* *text-window*)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; The End.
-